|
|
|
|
|
|
|
An array can be dimensioned to a certain fixed size at declaration time. Public fixed-size arrays may only be declared in a standard module, just as all other Public variables. Local and module-level arrays are declared as appropriate. To declare a fixed-size array, you put the number of elements you want inside parentheses following the variable name. Heres an example: |
|
|
|
 |
|
|
|
|
Public gastrSSN(3) As String
Public gastrNames(3) As String
Public gacurSalary(3) As Currency |
|
|
|
|
|
|
|
|
This code declares three public array variables that have been declared to hold four elements each, 0 to 3. Two of the arrays can hold String variables, whereas the third can only hold Currency data. To assign data to each element of the array, you simply specify the array name followed by parentheses and an index number of where you want the value to be placed in the array. |
|
|
|
|
|
|
|
|
Examples Filename: Arrays.frm |
|
|
|
|
| Look at Some Array Code 1. Double-click the Fixed Size command button to view the following code: | | Private Sub cmdFixed_Click()
' Set SSNs for Employees
gastrSSN(0) = "555-55-5555"
gastrSSN(1) = "123-45-6789"
gastrSSN(2) = "987-65-4321"
gastrSSN(3) = "333-33-3333"
' Set Names for Employees
gastrNames(0) = "Paul"
gastrNames(1) = "Ken"
gastrNames(2) = "Bill"
gastrNames(3) = "Tom". |
|
|
|